package powers;

import virtualTabletop.ActionType;
import virtualTabletop.AttackType;
import virtualTabletop.DamageType;
import virtualTabletop.TargetType;
import Items.Weapon;
import abilities.Ability;
import conditionsandeffects.Effect;
import defenses.Defense;

/**
 * for making powers
 * 
 * @author bjarte
 * 
 */
public class Power
{
	String name;
	Flavor flavor;
	PowerSource pwrSource;
	DamageType dmgType;
	EffectType efcType;
	Accessory accessory;
	ActionType actionType;
	AttackType atkType;
	int range;
	int withinSquares;
	TargetType target;
	int nbOfAttacks;
	AttackVs attackVs;
	private Hit hit;
	Boolean dmgOnFail;
	Effect effect;
	int duration;

	/**
	 * empty constructor
	 */
	public Power()
	{
	}

	/**
	 * constructor for powers
	 * 
	 * @param name
	 *            name of the power
	 * @param flavor
	 *            flavor of the power
	 * @param pwrSource
	 *            power source
	 * @param dmgType
	 *            damage type
	 * @param efcType
	 *            effect type
	 * @param accessory
	 *            accressory needed to use the power
	 * @param actionType
	 *            action type
	 * @param atkType
	 *            attack type
	 * @param range
	 *            range of the power
	 * @param withinSquares
	 *            within how many squares the power hits
	 * @param target
	 *            what type of target the power hits
	 * @param attackVs
	 *            what ability and against which defense the power is
	 * @param nbOfAttacks
	 *            number of attacks the power makes
	 * @param hit
	 *            amount of damage the power does
	 * @param dmgOnFail
	 *            how much damage the power does on fail.
	 * @param effect
	 *            effect the power does
	 * @param duration
	 *            duration of the effect the power has
	 */
	public Power(String name, Flavor flavor, PowerSource pwrSource,
			DamageType dmgType, EffectType efcType, Accessory accessory,
			ActionType actionType, AttackType atkType, int range,
			int withinSquares, TargetType target, AttackVs attackVs,
			int nbOfAttacks, Hit hit, Boolean dmgOnFail, Effect effect,
			int duration)
	{
		this.name = name;
		this.flavor = flavor;
		this.pwrSource = pwrSource;
		this.dmgType = dmgType;
		this.efcType = efcType;
		this.accessory = accessory;
		this.actionType = actionType;
		this.atkType = atkType;
		this.range = range;
		this.withinSquares = withinSquares;
		this.target = target;
		this.attackVs = attackVs;
		this.nbOfAttacks = nbOfAttacks;
		this.hit = hit;
		this.dmgOnFail = dmgOnFail;
		this.effect = effect;
		this.duration = duration;
	}

	/**
	 * rolls the damage the power does
	 * 
	 * @param weapon
	 *            the weapon used in the attack
	 * @param modifier
	 *            the modifier to the damage
	 * @return damage done
	 */
	public int rollDamage(Weapon weapon, int modifier)
	{
		return hit.roll(weapon, modifier);
	}

	/**
	 * the defense against the power
	 * 
	 * @return Defense
	 */
	public Defense defenseAgainst()
	{
		return attackVs.getDefense();
	}

	/**
	 * the ability used with the power
	 * 
	 * @return Ability
	 */
	public Ability attackWith()
	{
		return attackVs.getAbility();
	}

	@Override
	public String toString()
	{
		String s = new String();
		s += name + "\n";
		s += flavor + " " + pwrSource + " " + dmgType + " " + efcType + "\n";
		s += accessory + "\n";
		s += actionType + "\n";
		s += attackVs + "\n";
		s += hit + "\n";
		return s;
	}
}

/*
 * String name; Flavor flavor; PowerSource pwrSource; DamageType dmgType;
 * EffectType efcType; Accessory accessory; ActionType actionType; AttackType
 * atkType; int range; int withinSquares; TargetType target; int nbOfAttacks;
 * AttackVs attackVs; private Hit hit; Boolean dmgOnFail; Effect effect; int
 * duration;
 */
